<template>
  <div>
    <ul>
      <li v-for="(item, index) in arr" :key="item">
        {{ item }}
        <button @click="delFn(index)">删除</button>
      </li>
      <button @click="btnFn">生成</button>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [1, 5, 3, 7],
    }
  },
  methods: {
    btnFn() {
      this.arr.push(Math.floor(Math.random() * 10))
    },
    delFn(index) {
      this.arr.splice([index], 1)
    },
  },
}
</script>

<style></style>
